<?php


class Ext_View_Form_Admin_User extends Zend_Form
{
    public function init()
    {
        $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
        $bootstrap->bootstrap('view');
        $view = $bootstrap->getResource('view');
        $translate = Zend_Registry::get('Zend_Translate');
        
        $this->setAction($view->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'save-user-post'),'default',true))
                ->setMethod('post')
                ->setAttrib('id', 'mainForm')
                ->setAttrib('name', 'mainForm')
                ->setDecorators(array(
                    'FormElements', array('HtmlTag', array('tag' => 'dl', 'class'=>'formUiB')),
                    'Form',
                  ))
                ->setTranslator($translate);
            ;
            
        $formElements = array();
        
        $formElement = new Zend_Form_Element_Hidden('userId');
        $formElement->removeDecorator('DtDdWrapper');
        $formElement->removeDecorator('HtmlTag');
        $formElement->removeDecorator('Label');
        $formElements[] = $formElement;
        
        $formElement = new Zend_Form_Element_Text('nickname');
        $formElement
            ->setLabel($translate->_("Nickname"))
            ->setRequired(true)
            ->addValidator('NotEmpty')
            ->setAttrib('validate', '{required:true}')
            ->setDescription("Please enter a nickname.")
            ->setDecorators(array(
                        'ViewHelper',
                        array('Description', array('class' => 'tip', 'tag' => "div", 'id' => "nicknameTip")),
                        array('HtmlTag', array('tag' => 'dd')),
                        array('Label', array('tag' => 'dt')),
                        'Errors',
                      ))
            ;
        $formElements[] = $formElement;
        
        $formElement = new Zend_Form_Element_Select('roleId');
        $formElement->setLabel($translate->_("Role id"))
                    ->setRequired(true)
                    ->addValidator('NotEmpty')
                    ->setAttrib('validate', '{required:true}')
                    ->setDescription("Please select a option.")
                    ->setDecorators(array(
                        'ViewHelper',
                        array('Description', array('class' => 'tip', 'tag' => "div", 'id' => "roleIdTip")),
                        array('HtmlTag', array('tag' => 'dd')),
                        array('Label', array('tag' => 'dt')),
                        'Errors',
                      ))
            ;
        $formElements[] = $formElement;
        
        $formElement = new Zend_Form_Element_Submit('submit');
        $formElement->setLabel("Submit");
        $formElements[] = $formElement;
        
        $this->addElements($formElements);
    }

}
